﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public class PeerReviewBeenVoterCls
    {

        /// <summary>
        /// Dal定义的便利
        /// </summary>
        private readonly DAL.PeerReviewBeenVoterCls dal = new DAL.PeerReviewBeenVoterCls();

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <returns>是否更新</returns>
        public bool Add(ElingOA6_Admin_DSJCJ.Model.PeerReviewBeenVoterCls model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <returns>是否更新</returns>
        public bool Update(ElingOA6_Admin_DSJCJ.Model.PeerReviewBeenVoterCls model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="beenVoterClsCd">被评选人编号</param>
        /// <param name="peerReviewID">主题ID</param>
        /// <returns>得到一个对象实体</returns>
        public ElingOA6_Admin_DSJCJ.Model.PeerReviewBeenVoterCls GetModel(string beenVoterClsCd, decimal peerReviewID)
        {
            return dal.GetModel(beenVoterClsCd, peerReviewID);
        }

        /// <summary>
        /// 批量删除数据 
        /// <creator>chenly</creator>
        /// <date>2013-10-19</date>
        /// </summary>
        /// <param name="array">编号数组</param>
        public void DelMany(string beenVoterClsCd, decimal peerReviewID)
        {
            dal.DelMany(beenVoterClsCd, peerReviewID);
        }
        /// <summary>
        /// 得到所有数据
        /// </summary>
        /// <returns>集合模式</returns>
        public List<Model.PeerReviewBeenVoterCls> GetAll()
        {
            DataSet ds = dal.GetAll();
            return DataTableToListVoterCls(ds.Tables[0]);
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="beenVoterClsCd">编号</param>
        /// <param name="peerReviewID">主题</param>
        /// <returns>是否存在该记录</returns>
        public bool Exists(string FBeenVoterClsCd, decimal FPeerReviewID)
        {
            return dal.Exists(FBeenVoterClsCd, FPeerReviewID);
        }

        /// <summary>
        ///  获得数据列表
        /// <summary>
        /// <creator>chenly</creator>
        /// <date>2013-10-18</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.PeerReviewBeenVoterCls> DataTableToListVoterCls(DataTable dt)
        {
            List<Model.PeerReviewBeenVoterCls> modelList = new List<Model.PeerReviewBeenVoterCls>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.PeerReviewBeenVoterCls model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.PeerReviewBeenVoterCls();
                    if (dt.Rows[n]["FBeenVoterClsCd"] != null)
                    {
                        model.FBeenVoterClsCd = dt.Rows[n]["FBeenVoterClsCd"].ToString();
                    }
                    if (dt.Rows[n]["FPeerReviewID"] != null && dt.Rows[n]["FPeerReviewID"].ToString() != "")
                    {
                        model.FPeerReviewID = decimal.Parse(dt.Rows[n]["FPeerReviewID"].ToString());
                    }
                    if (dt.Rows[n]["FBeenVoterClsName"] != null)
                    {
                        model.FBeenVoterClsName = dt.Rows[n]["FBeenVoterClsName"].ToString();
                    }
                    if (dt.Rows[n]["FDispSeq"] != null && dt.Rows[n]["FDispSeq"].ToString() != "")
                    {
                        model.FDispSeq = int.Parse(dt.Rows[n]["FDispSeq"].ToString());
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="beenVoterClsCd">被评选人类别编号</param>
        /// <param name="peerReviewID">主题编号</param>
        /// <returns>是否删除</returns>
        public bool Delete(string beenVoterClsCd, decimal peerReviewID)
        {
            return dal.Delete(beenVoterClsCd, peerReviewID);
        }

    }
}
